[create a Namespace]
$ kubectl create namespace cpu-example

[create the 1st Pod]
$ kubectl apply -f Pod_1.yaml --namespace=cpu-example
$ kubectl apply -f https://k8s.io/examples/pods/resource/cpu-request-limit.yaml --namespace=cpu-example

[verify that the Pod is running]
$ kubectl get pod cpu-demo --namespace=cpu-example

[view detailed information about the Pod]
$ kubectl get pod cpu-demo --output=yaml --namespace=cpu-example
..........
..........
resources:
  limits:
    cpu: "1"
  requests:
    cpu: 500m
..........
..........

● The output shows that the one container in the Pod has a CPU request of 500 milliCPU and a CPU limit of 1 CPU.

[fetch the metrics for the Pod]
$ kubectl top pod cpu-demo --namespace=cpu-example
NAME                        CPU(cores)   MEMORY(bytes)
cpu-demo                    974m         <something>

● The output shows that the Pod is using 974 milliCPU, which is slightly less than the limit of 1 CPU specified in the Pod configuration.

[delete Pod]
$ kubectl delete pod cpu-demo --namespace=cpu-example

[create the 2nd Pod]
$ kubectl apply -f Pod_2.yaml --namespace=cpu-example
$ kubectl apply -f https://k8s.io/examples/pods/resource/cpu-request-limit-2.yaml --namespace=cpu-example

[view the Pod status]
$ kubectl get pod cpu-demo-2 --namespace=cpu-example
NAME         READY     STATUS    RESTARTS   AGE
cpu-demo-2   0/1       Pending   0          7m

● The output shows that the Pod status is Pending.
● Pod has not been scheduled to run on any Node, and it will remain in the Pending state indefinitely.

[view detailed information about the Pod, including events]
$ kubectl describe pod cpu-demo-2 --namespace=cpu-example
..........
..........
Events:
  Reason                        Message
  ------                        -------
  FailedScheduling      No nodes are available that match all of the following predicates:: Insufficient cpu (3).
..........
..........

● The output shows that the Container cannot be scheduled because of insufficient CPU resources on the Nodes.

[delete Pod]
$ kubectl delete pod cpu-demo-2 --namespace=cpu-example

[delete Namespace]
$ kubectl delete namespace cpu-example


[If you do not specify a CPU limit]
The Container has no upper bound on the CPU resources it can use. 
The Container could use all of the CPU resources available on the Node where it is running.
The Container is running in a namespace that has a default CPU limit, and the Container is automatically assigned the default limit. 
Cluster administrators can use a LimitRange to specify a default value for the CPU limit.

[If you specify a CPU limit but do not specify a CPU request]
If you specify a CPU limit for a Container but do not specify a CPU request, Kubernetes automatically assigns a CPU request that matches the limit.
If a Container specifies its own memory limit, but does not specify a memory request, Kubernetes automatically assigns a memory request that matches the limit.
